package com.kyzh.core.dialog

import android.annotation.SuppressLint
import android.app.Activity
import android.view.LayoutInflater
import android.view.View
import androidx.appcompat.app.AlertDialog
import androidx.databinding.DataBindingUtil
import com.kyzh.core.R
import com.kyzh.core.databinding.DialogExitQunBinding

private var exchangeDialog: AlertDialog?=null

fun Activity.showExitQunDialog(listener:()->Unit){
    exchangeDialog = AlertDialog.Builder(this, R.style.kyzhGuestLoginDialog)
        .setView(getView(listener))
        .create()

    exchangeDialog?.show()
}
@SuppressLint("ClickableViewAccessibility")
private fun Activity.getView( listener:()->Unit): View {
    val binding = DataBindingUtil.inflate<DialogExitQunBinding>(
        LayoutInflater.from(this),
        R.layout.dialog_exit_qun,null,false)
    binding.btGet.setOnClickListener {
        listener()
        exchangeDialog?.dismiss()
    }
    binding.cancel.setOnClickListener {
        exchangeDialog?.dismiss()
    }
    return binding.root
}